import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  // 重定向
  { path: '/re', redirect: '/' },
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/about',
    name: 'About',
    component: () => import('../views/About.vue')
  },
  {
    path: '/detail/:id',
    name: 'Detail',
    component: () => import('../views/Detail.vue')
  },
  {
    path: '/class',
    name: 'class',
    component: () => import('../views/Class.vue')
  },
  {
    path: '/nav',
    name: 'nav',
    component: () => import('../views/Nav.vue')
  },
  {
    path: '/animate',
    name: 'animate',
    component: () => import('../views/Animate.vue')
  },
  // 容错
  {
    path: '/*',
    name: 'error',
    component: () => import('../views/Home.vue')
  },
  // Films
  {
    path: '/films',
    name: 'Films',
    component: () => import('../views/Films/Films.vue'),
    children:[
      {
        path: 'nowplaying',//这里不需要反斜杠开头
        component: () => import('../views/Films/NowPalying.vue'),
      },
      {
        path: 'comingsoon',
        component: () => import('../views/Films/ComingSoon.vue'),
      }
    ]
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
